﻿using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;

namespace klg_client.library
{
    public class ScreenShotMgr
    {
        private static ScreenShotMgr _instance;

        public static ScreenShotMgr Instance
        {
            get { return _instance ?? (_instance = new ScreenShotMgr()); }
        }

        public byte[] GetScreenImage()
        {
            using (var bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height))
            {
                var graphics = Graphics.FromImage(bitmap);
                graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);
                var stream = new MemoryStream();
                bitmap.Save(stream, ImageFormat.Jpeg);
                return stream.GetBuffer();
            }
        }
    }
}
